package com.jinke.api.modules.ums.model;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.jinke.api.modules.base.model.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;

/**
 * <p>
 * 配置表
 * </p>
 *
 * @author macro
 * @since 2024-01-16
 */
@Getter
@Setter
@TableName("system_config")
@ApiModel(value = "SystemConfig对象", description = "配置表")
public class SystemConfig extends BaseEntity {

    @ApiModelProperty("配置项名称")
    private String configName;

    @ApiModelProperty("配置项Key")
    private String configKey;

    @ApiModelProperty("配置项描述")
    private String configDesc;

    @ApiModelProperty("类型，数值输入框number、文本输入框text、开关switch")
    private String configType;

    @ApiModelProperty("分组，主要看前端要不要做成多个tab")
    private String configGroup;

    @ApiModelProperty("配置值")
    private String configValue;


    @JsonIgnore
    public Integer toInteger() {
        return Integer.parseInt(getConfigValue());
    }

    @JsonIgnore
    public BigDecimal toBigDecimal() {
        return new BigDecimal(getConfigValue());
    }

    @JsonIgnore
    public Boolean toBoolean() {
        return !getConfigValue().equals("0");
    }

}
